#pragma once
#include"Logger.h"
#include<sstream>
namespace tmms
{   
    namespace base{
        extern Logger* g_loger;
        class LogStream{
        public:
            LogStream(Logger* log,const char* file,int line,LogLevel level,const char* func = nullptr);
            ~LogStream();
            template<class T> LogStream & operator<<(const T& value){
                stream_<<value;
                return *this;
            }

        private:
            std::ostringstream stream_;
            Logger* logger_{nullptr};
        };
    }
}

#define LOG_TRACE \
    if(tmms::base::g_loger->GetLogLevel()<=tmms::base::kTrace)\
        tmms::base::LogStream(tmms::base::g_loger,__FILE__,__LINE__,tmms::base::kTrace,__func__)
#define LOG_DEBUG \
    if(tmms::base::g_loger->GetLogLevel()<=tmms::base::kDebug)\
        tmms::base::LogStream(tmms::base::g_loger,__FILE__,__LINE__,tmms::base::kDebug,__func__)
#define LOG_INFO \
    if(tmms::base::g_loger->GetLogLevel()<=tmms::base::kInfo)\
        tmms::base::LogStream(tmms::base::g_loger,__FILE__,__LINE__,tmms::base::kInfo,__func__)
#define LOG_WARN \
    tmms::base::LogStream(tmms::base::g_loger,__FILE__,__LINE__,tmms::base::kWarn)
#define LOG_ERROR \
    tmms::base::LogStream(tmms::base::g_loger,__FILE__,__LINE__,tmms::base::kError)
